package com.congee02.utils;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

/**
 * @author congee(congee02 @ 163.com)
 * @date 1/27/2023 9:43 AM
 */
public class FileUtils {

    private FileUtils() {
    }

    private static List<File> ergodic(File file, List<File> resultFiles) {
        File[] files = file.listFiles();
        if (file == null) {
            return List.of();
        }
        for (File f : files) {
            if (f.isDirectory()) {
                ergodic(f, resultFiles);
            } else {
                resultFiles.add(f);
            }
        }
        return resultFiles;
    }

    public static List<File> ergodic(File file) {
        return ergodic(file, new ArrayList<>());
    }

}
